Skip to content

Method: Predicate.BooleanOperator(String, int, String)

1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.model.query.criteria;
19:
20: import java.util.List;
21:
22: public interface Predicate extends Expression<Boolean> {
23:
24: /**
25: * Return the top-level conjuncts or disjuncts of the predicate. Returns empty list if there are no top-level
26: * conjuncts or disjuncts of the predicate.
27: *
28: * @return list of boolean expressions forming the predicate
29: */
30: List<Expression<Boolean>> getExpressions();
31:
32: /**
33: * Return the boolean operator for the predicate. If the predicate is simple, this is AND.
34: *
35: * @return boolean operator for the predicate
36: */
37: Predicate.BooleanOperator getOperator();
38:
39: /**
40: * Create a negation of the predicate.
41: *
42: * @return negated predicate
43: */
44: Predicate not();
45:
46: /**
47: * Determines if the predicate has been created from another predicate by applying the Predicate.not() method.
48: *
49: * @return boolean indicating if the predicate is a negated predicate
50: */
51: boolean isNegated();
52:
53: enum BooleanOperator {
54: AND("AND"),
55: OR("OR");
56:
57: private final String operator;
58:
59: BooleanOperator(String operator) {
60: this.operator = operator;
61: }
62:
63: @Override
64: public String toString() {
65: return operator;
66: }
67: }
68: }